﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Caliburn.Micro;
using MdcService.Service;

namespace MdcMain
{
    public class SettingViewModel:Screen
    {
        private ConfigurationService _service;


        public bool RestService
        {
            get => _service.Configuration.RestService;
            set
            {
                _service.Configuration.RestService = value;
                NotifyOfPropertyChange(nameof(RestService));
            }
        }
        public string RealtimeDbAppPath
        {
            get => _service.Configuration.RealtimeDbAppPath;
            set
            {
                _service.Configuration.RealtimeDbAppPath = value;
                NotifyOfPropertyChange(nameof(RealtimeDbAppPath));
            }
        }

        public string RealtimeDbConnectionString
        {
            get => _service.Configuration.RealtimeDbConnectionString;
            set
            {
                _service.Configuration.RealtimeDbConnectionString = value;
                NotifyOfPropertyChange(nameof(RealtimeDbConnectionString));
            } } 
        public string HistoryDbConnectionString
        {
            get => _service.Configuration.HistoryDbConnectionString;
            set
            {
                _service.Configuration.HistoryDbConnectionString = value;
                NotifyOfPropertyChange(nameof(HistoryDbConnectionString));
            } }

        public int ConnectionInterval
        {
            get => _service.Configuration.ConnectionInterval;
            set
            {
                _service.Configuration.ConnectionInterval = value;
                NotifyOfPropertyChange(nameof(ConnectionInterval));
            } } 
        public int FetchValueInterval
        {
            get => _service.Configuration.FetchValueInterval;
            set
            {
                _service.Configuration.FetchValueInterval = value;
                NotifyOfPropertyChange(nameof(FetchValueInterval));
            } } 
        public int ConnectionMaxThreads
        {
            get => _service.Configuration.ConnectionMaxThreads;
            set
            {
                _service.Configuration.ConnectionMaxThreads = value;
                NotifyOfPropertyChange(nameof(ConnectionMaxThreads));
            } } 

        public int FetchValueMaxThreads
        {
            get => _service.Configuration.FetchValueMaxThreads;
            set
            {
                _service.Configuration.FetchValueMaxThreads = value;
                NotifyOfPropertyChange(nameof(FetchValueMaxThreads));
            } } 
        public int ConnectionRetryParamK
        {
            get => _service.Configuration.ConnectionRetryParamK;
            set
            {
                _service.Configuration.ConnectionRetryParamK = value;
                NotifyOfPropertyChange(nameof(ConnectionRetryParamK));
            } } 
        public int ConnectionRetryParamN
        {
            get => _service.Configuration.ConnectionRetryParamN;
            set
            {
                _service.Configuration.ConnectionRetryParamN = value;
                NotifyOfPropertyChange(nameof(ConnectionRetryParamN));
            } } 
        public int HistoryCollectionInterval
        {
            get => _service.Configuration.HistoryCollectionInterval;
            set
            {
                _service.Configuration.HistoryCollectionInterval = value;
                NotifyOfPropertyChange(nameof(HistoryCollectionInterval));
            } } 
        public string MachineDefinitionPath
        {
            get => _service.Configuration.MachineDefinitionPath;
            set
            {
                _service.Configuration.MachineDefinitionPath = value;
                NotifyOfPropertyChange(nameof(MachineDefinitionPath));
            } } 
        public string MachineDefinitionExt
        {
            get => _service.Configuration.MachineDefinitionExt;
            set
            {
                _service.Configuration.MachineDefinitionExt = value;
                NotifyOfPropertyChange(nameof(MachineDefinitionExt));
            } } 


        public SettingViewModel(ConfigurationService service)
        {
            DisplayName = "设置";
            
            _service = service;
            
        }

        public void Ok()
        {
            _service.Save();
            TryClose();
        }

        public void Cancel()
        {
            TryClose();
        }


    }
}
